/**
 * 
 */
package com.jukte.recipe;

import com.ewhat.recipes.R;
import com.jukte.recipe.share.FacebookShareActivity;
import com.jukte.recipe.share.TwitterShareActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class ShareTabFragment extends Fragment implements OnClickListener{

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
	private Button fbShareBtn,twitterShareBtn,mailBtn;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (container == null) {
            return null;
        }
		View view=inflater.inflate(R.layout.frag_share, container,false);

		fbShareBtn=(Button)view.findViewById(R.id.fb_btn);
		fbShareBtn.setOnClickListener(this);
		twitterShareBtn=(Button)view.findViewById(R.id.tw_btn);
		twitterShareBtn.setOnClickListener(this);
		mailBtn=(Button)view.findViewById(R.id.mail_btn);
		mailBtn.setOnClickListener(this);
		return view;
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v==fbShareBtn)
		{
			getActivity().startActivity(new Intent(getActivity(), FacebookShareActivity.class));
		}
		else if(v==twitterShareBtn)
		{
			getActivity().startActivity(new Intent(getActivity(), TwitterShareActivity.class));
		}
		else if(v==mailBtn)
		{
			String status=getString(R.string.app_caption_share)+"\n"+getString(R.string.app_description_share)+"\n"+"https://play.google.com/store/apps/details?id=com.ewhat.recipes";
			Intent emailIntent = new Intent(
					android.content.Intent.ACTION_SEND);
			emailIntent.setType("plain/text");
			emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,status);
			emailIntent.putExtra(Intent.EXTRA_SUBJECT, R.string.app_name);
			startActivity(Intent.createChooser(emailIntent, "Send mail..."));

		}
			
	}

	
}
